/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package demo916;

/**
 *
 * @author Administrator
 */
import java.util.Scanner;

/**
 *
 * @author Administrator
 */
public class MainB {
    public static void main(String[] args) { 
     Scanner cin = new Scanner(System.in); 
     int mm[]={31,28,31,30,31,30,31,31,30,31,30,31}; 
     int year, month; 
            year = cin.nextInt(); 
            month = cin.nextInt(); 
            if(isLeapYear(year)&&month==2){
                System.out.println(29);
            }else{
                System.out.println(mm[month-1]);
            }
    } 

    public static boolean isLeapYear(int year) { 
        return (year % 4 == 0 && year % 100 != 0) || ((year % 400) == 0); 
        
    } 
}
